class Threepeater extends GuaAnimation {
    static new(game) {
        let p = new this(game, animationThreepeater)
        p.setup()
        return p
    }

    setup() {
        // row表示在草地的第几排
        this.row = -1
        this.cooldown = 5
        this.score = 325
        this._sleep = true
    }

    awake() {
        this._sleep = false
    }

    sleep() {
        this._sleep = true
    }

    fire() {
        // 没有僵尸不发射
        if (this._sleep) {
            return
        }
        this.cooldown--
        if (this.cooldown == 0) {
            // 开始冷却
            this.cooldown = 20
            // 发射子弹
            let s = this.game.scene
            for (let i = 0; i < 3; i++) {
                let pb = PeaBullet.new(this.game, 'peabullet1')
                let fix = 30
                pb.x = this.x + fix
                pb.y = this.y + i * 10
                pb.row = this.row
                this.game.scene.addElement(pb)
                s.addElement(pb)
                s.bullets.push(pb)
            }
        }
    }

    update() {
        super.update()
        this.fire()
    }
}